<?PHP
session_start();
include("../config/connect.php");
include("../public/common.php");

if( !isset($_SESSION["gs_user"]) ) 
{
	$url = "Location:login.php";
	header($url);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>购物兔</title>
<style type="text/css">
<!--
body,td,th {
	font-family: 宋体;
	font-size: 13px;
	color: #000;
}
body {
	background-color: #FFF;
}
-->
</style>
</head>
<body>
<a href="view_discount.php">返回</a>
<table cellpadding="0" cellspacing="0" border="1" align="center">
	<tr>
    	<td height="25" width="50" align="center">序列号</td>
        <td width="200" align="center">时间</td>
      	<td width="150" align="center">产品Id</td>
        <td width="70" 	align="center">返现(元)</td>
        <td width="150" align="center">交易流水号</td>
        <td width="162" align="center">支付宝帐号</td>
        <td width="140" align="center">ip</td>
        <td width="22" align="center">转换</td>
        <td width="60" align="center">操作</td>
        <td width="22" align="center">返现</td>
    </tr>
<?php
$id = SetUrlParamInt("id");
$opt = CheckUrlParamNoDie( "opt" );
$all = CheckUrlParamNoDie( "all" );
$tb_id = CheckUrlParamNoDie( "tb_id" );
$nPage = CheckUrlParamNoDie( "page" );
$showtype = CheckUrlParamNoDie( "showtype" );

if( $id != 0 && $opt == "return" )
{
	$sql = "update trade set has_return=1 where id=$id";
	mysql_query( $sql );
	echo "<script>window.history.back()</script>";
	exit;
}

if( $all == "1" )
{
	if( $tb_id == "" )
		$sql = "select * from trade where 1 order by id desc";
	else
		$sql = "select * from trade where tb_id='$tb_id' order by id desc";
}
else
{
	if( $tb_id == "" )
		$sql = "select * from trade where has_return=0 order by id desc";
	else
		$sql = "select * from trade where has_return=0 and tb_id='$tb_id' order by id desc";
}
$result = mysql_query( $sql );
while( $result && $row = mysql_fetch_assoc( $result ))
{
	if( $row["use_discount"] == "1" )
		$use_discount = "<strong><span style=\"color:#F00\">是</span></strong>";
	else
		$use_discount = "否";
		
	if( $row["has_return"] == 1 )
		$has_return = "<strong><span style=\"color:#F00\">是</span></strong>";
	else
		$has_return = "否";
?>
<tr title="<?PHP echo $row["info"]; ?>">
    <td height="25" width="50" align="center"><?PHP echo $row["id"]; ?></td>
    <td width="200" align="center" title=""><?PHP echo $row["time"]; ?></td>
	<td width="150" align="center"><?PHP echo $row["item_id"]; ?>&nbsp;</td>
	<td width="70" 	align="center"><?PHP echo $row["discount"]; ?>&nbsp;</td>
	<td width="150" align="center"><a href="view_trade.php?page=<?PHP echo $nPage; ?>&trade=<?PHP echo $row["trade_id"]; ?>&showtype=<?PHP echo $showtype; ?>"><?PHP echo $row["trade_id"]; ?></a>&nbsp;</td>
	<td width="162" align="center"><?PHP echo $row["tb_id"]; ?>&nbsp;</td>
    <td width="140" align="center"><?PHP echo $row["ip"]; ?>&nbsp;</td>
    <td width="22" align="center"><?PHP echo $use_discount; ?>&nbsp;</td>
	<td width="60" align="center"><a href="view_user.php?opt=return&all=<?PHP echo $all; ?>&tb_id=<?PHP echo $tb_id; ?>&id=<?PHP echo $row["id"]; ?>">标识返现</a></td>
    <td width="22" align="center"><?PHP echo $has_return; ?>&nbsp;</td>
</tr>
<?PHP
}
?>
</table>
</body>
</html>